home *** CD-ROM | disk | FTP | other *** search
/ AmigActive 23 / AACD 23.iso / AACD / Programming / tek / array / stringcopystr.c < prev    next >
C/C++ Source or Header  |  2001-05-12  |  486b  |  32 lines

  1.  
  2. #include "tek/array.h"
  3.  
  4. /* 
  5. **    TEKlib
  6. **    (C) 2001 TEK neoscientists
  7. **    all rights reserved.
  8. **
  9. **    TBOOL TStringCopyStr(TSTRPTR *s1, TSTRPTR s2)
  10. **
  11. **    copy regular string to a dynamic string.
  12. **
  13. */
  14.  
  15. TBOOL TStringCopyStr(TSTRPTR *s1, TSTRPTR s2)
  16. {
  17.     if (*s1)
  18.     {
  19.         TARRAY *a1 = *((TARRAY **) s1) - 1;
  20.         if (a1->valid)
  21.         {
  22.             TUINT newlen = TStrLen(s2);
  23.             if (TArraySetLen((TAPTR *) s1, newlen + 1))
  24.             {
  25.                 TMemCopy(s2, *s1, newlen + 1);
  26.                 return TTRUE;    
  27.             }
  28.         }
  29.     }
  30.     return TFALSE;
  31. }
  32.